package com.ruoyi.web.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.course.domain.SysCourseStudent;
import com.ruoyi.course.service.ISysCourseStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/course/student")
public class SysCourseStudentApi extends BaseController {
    @Autowired
    private ISysCourseStudentService studentService;

    @GetMapping("/list")
    public TableDataInfo getByStudentId(){
        long uid = getUserId();
        List<SysCourseStudent> list = studentService.getByStudentId(uid);
        return getDataTable(list);
    }

    @PostMapping("/save")
    public AjaxResult save(@RequestBody SysCourseStudent student){
        student.setStudentId(getUserId());
        studentService.saveCourseRate(student);
        return AjaxResult.success();
    }
}
